#异常处理
# try:
#   print('成功')
# except IOError as e:
#     print('失败')
#     pass


# try:
#     print("-------1------")
#     f  = open('test.txt','r')
#     print(a)
#     print("-------2------")
# except Exception as e: #对错误捕获 捕获所有异常
#     print(e)

import time
try:
    f = open('test1.txt','r',encoding='utf-8')
    try:
        while True:
            content = f.readline()
            if len(content) == 0:
                break
            time.sleep(2)
            print(content)
    finally:
        f.close()
        print('关闭')
except Exception as e:
    print('发生异常',e)

